﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Diagnostics;
using System.IO;

namespace MemoryLoadStatistics.Models
{
    public class ReadDataHDD : IReaderData
    {
        private PerformanceCounter HDD;
        #region
        //private PerformanceCounter AVG;
        //private PerformanceCounter Physical;
        ////private PerformanceCounter Trancfer;
        //private PerformanceCounter Transfer;
        //private PerformanceCounter length;
        #endregion

        public ReadDataHDD()
        {
            PerformanceCounterCategory category = new System.Diagnostics.PerformanceCounterCategory("PhysicalDisk");
            string[] instanceNames = category.GetInstanceNames();

            this.HDD = new PerformanceCounter("PhysicalDisk", "% Idle Time", instanceNames[0]);
            #region
            //this.AVG = new PerformanceCounter("LogicalDisk", "Avg. Disk sec/Transfer", "_Total");
            //this.Transfer = new PerformanceCounter("LogicalDisk", "Disk Transfers/sec", "_Total");
            //this.length = new PerformanceCounter("LogicalDisk", "Avg. Disk Queue Length", "_Total");
            //this.Physical = new PerformanceCounter("PhysicalDisk", "% Idle Time", instanceNames[0]);
            #endregion
        }

        public byte GetData()
        {
            #region
            //float active = this.HDD.NextValue();
            //float avg = this.AVG.NextValue();
            //float transfer = this.Transfer.NextValue();
            //float lenght = this.length.NextValue();
            //float physical = this.Physical.NextValue();
            #endregion
            return (byte)(100 - HDD.NextValue());
        }
    }
}